import { request } from '../utils/request';

export async function fetchMethodPageQuery(params: any) {
    return request({
        url: '/method/info/pageQuery',
        method: 'post',
        data: params,
    });
}

// 导出方法数据（异步）
export async function exportMethods(params: any) {
    return request({
        url: '/method/info/export',
        method: 'post',
        data: params,
    });
}

// 查询导出任务状态
export async function getExportStatus(taskId: number) {
    return request({
        url: `/method/info/export/${taskId}/status`,
        method: 'get',
    });
}

// 下载导出文件
export function downloadExportFile(taskId: number) {
    const url = `/api/method/info/export/${taskId}/download`;
    const link = document.createElement('a');
    link.href = url;
    link.download = '';
    document.body.appendChild(link);
    link.click();
    document.body.removeChild(link);
}